﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aier.dataaccess.model
{
    /// <summary>
    /// 患者信息
    /// </summary>
    public class ReferralPatientDto
    {
        /// <summary>
        /// 患者姓名
        /// </summary>
        [Required]
        public string name { get; set; }

        /// <summary>
        /// 患者性别
        /// </summary>
        [Required]
        public int sex { get; set; }

        /// <summary>
        /// 患者年龄
        /// </summary>
        public int age { get; set; }

        /// <summary>
        /// 患者生日
        /// </summary>
        public DateTime? birthdate { get; set; }

        /// <summary>
        /// 患者电话
        /// </summary>
        [Required]
        public string telephone { get; set; }

        /// <summary>
        /// 患者身份证
        /// </summary>
        public string citizenid { get; set; }

        /// <summary>
        ///  患者常住详细地址
        /// </summary>
        public string address { get; set; }

        /// <summary>
        /// 详情描述
        /// </summary>
        public string description { get; set; }

        /// <summary>
        /// 建档场景
        /// </summary>
        [Required]
        [PickListValidate(NotValues = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 99 }, ErrorMessage = "值不不在范围内")]
        public int patientsource { get; set; }

        /// <summary>
        /// 建档场景说明
        /// </summary>
        public string sourceremark { get; set; }

        /// <summary>
        /// 推广来源
        /// </summary>
        [Required]
        public int promotionsource { get; set; } = 100000024;


        /// <summary>
        /// 病种
        /// </summary>
        [Required]
        [Range(1, 15)]
        public int disease { get; set; }

        /// <summary>
        /// 是否幼儿筛查
        /// </summary>
        [Required]
        [Range(0, 1)]
        public int infantscreening { get; set; }

        /// <summary>
        /// 科普
        /// </summary>
        public bool popularscience { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Required]
        public DateTime? createtime { get; set; }


        /// <summary>
        /// 接诊人CRM账号
        /// </summary>
        [Required]
        public string owneridname { get; set; }

        /// <summary>
        /// 转出人OA
        /// </summary>
        public string referraloutoa { get; set; }

        /// <summary>
        /// 转出人姓名
        /// </summary>
        public string referraloutname { get; set; }

        /// <summary>
        /// 转出医院人资编码
        /// </summary>
        public string referraloutcode { get; set; }

        /// <summary>
        /// 转出医院名称
        /// </summary>
        public string referralouthospital { get; set; }

        /// <summary>
        /// 是否需要随访（1是，0否，默认是）
        /// </summary>
        public Int16 isfollow { get; set; }

        /// <summary>
        ///  随访日期
        /// </summary>
        public DateTime followdate { get; set; }

        /// <summary>
        /// 认同医生
        /// </summary>
        public string identifydoctor { get; set; }

        /// <summary>
        /// 期望术式
        /// </summary>
        public string expectedoperation { get; set; }
        /// <summary>
        /// 安全诉求
        /// </summary>
        public string safetydemands { get; set; }

        /// <summary>
        /// 价格敏感
        /// </summary>
        public string pricesensitivity { get; set; }

        /// <summary>
        /// 可享优惠
        /// </summary>
        public string benefitsavailable { get; set; }       

    }

    public class PickListValidate : ValidationAttribute
    {
        public int[] NotValues { get; set; }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var result = ValidationResult.Success;

            var inValue = (int)value;

            var isexists = NotValues.Where(t => t == inValue).Count() > 0;
            if (!isexists)
            {
                result = new ValidationResult(ErrorMessage);
            }


            return result;
        }
    }
}
